package ua.org.enginer.tracking
{
	import flash.events.Event;
	
	import mx.controls.List;
	
	public class ListTrackingImpl extends UIComponentTrackingImpl
	{
		public function ListTrackingImpl(target:List) {
			super(target)
			List(target).addEventListener(Event.CHANGE, onChange)
		}
		
		protected function onChange(event:Event):void {
			var item:Object = List(target).selectedItem
			var value:String
			
			if (item) {
				if (item.hasOwnProperty('label')) {
					value = item['label']
				}else {
					value = item.toString()
				}
			}
			
			tracker.trackEvent(trackingName, "change", value)
		}
	}
}